home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume91 / libraris / smalfprs / part02 < prev   
Internet Message Format  |  1991-03-15  |  24KB

  1. Path: news.larc.nasa.gov!amiga-request
  2. From: amiga-request@ab20.larc.nasa.gov (Amiga Sources/Binaries Moderator)
  3. Subject: v91i063: SmallIFFParse.library - Small IFF Parser library, Part02/02
  4. Reply-To: Michael Jansson <mij@IDA.LiU.SE>
  5. Newsgroups: comp.sources.amiga
  6. Message-ID: <comp.sources.amiga:v91i063@ab20.larc.nasa.gov>
  7. References: <comp.sources.amiga:v91i062@ab20.larc.nasa.gov>
  8. Date: 14 Mar 91 01:46:19 GMT
  9. Approved: tadguy@uunet.UU.NET (Tad Guy)
  10. X-Mail-Submissions-To: amiga@uunet.uu.net
  11. X-Post-Discussions-To: comp.sys.amiga.misc
  12.  
  13. Submitted-by: Michael Jansson <mij@IDA.LiU.SE>
  14. Posting-number: Volume 91, Issue 063
  15. Archive-name: libraries/smalliffparse/part02
  16.  
  17. #!/bin/sh
  18. # This is a shell archive.  Remove anything before this line, then unpack
  19. # it by saving it into a file and typing "sh file".  To overwrite existing
  20. # files, type "sh file -c".  You can also feed this as standard input via
  21. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  22. # will see the following message at the end:
  23. #        "End of archive 2 (of 2)."
  24. # Contents:  binaries/pasteclip.uu sources/handleiff.c
  25. # Wrapped by tadguy@ab20 on Wed Mar 13 20:46:16 1991
  26. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  27. if test -f 'binaries/pasteclip.uu' -a "${1}" != "-c" ; then 
  28.   echo shar: Will not clobber existing file \"'binaries/pasteclip.uu'\"
  29. else
  30. echo shar: Extracting \"'binaries/pasteclip.uu'\" \(9262 characters\)
  31. sed "s/^X//" >'binaries/pasteclip.uu' <<'END_OF_FILE'
  32. Xbegin 666 pasteclip
  33. XM```#\P`````````#``````````(```6H````QP````$```/I```%J$[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L9.KOYB3-]``$*L@O!@`/]`:6-O;BYL:6)RC
  82. XM87)Y`%=)3D1/5P`J`$SO`P``!"`((B\`#&`"$-E7R?_\9PP$@0`!``!J\$YU1
  83. XM0AA1R?_\!($``0``:O).=4Y5_?A(YS\R)FT`""QM`!!^`"1M``P6$F8*,`=,&
  84. XMWTS\3EU.=5**#`,`)6=`-`<@4['K``1D#"!34I,0@W``$`-@#G``$`,_`"\+B
  85. XM3KH%6EQ/#$#__V<`!$A20A829@0P`F"Z4HH,`P`E9L0^`G@`.WP`(/_^%AIPG
  86. XM`!`#8%X(Q```8/((Q``!8.P(Q``"8.8(Q``#8.!4CC0N__Y*0FP&",0``$1"\
  87. XM%AI@3CM\`##__G0`8!8P`N=`<@`2`]!!T$+00C0`!$(`,!8:<``0`T'L@`,(6
  88. XM,``"``!FVF`<!$``(&>H5T!GJE]`9ZQ30&>654!GC%=`9[1@N#M"__PT/'W&(
  89. XM#`,`+F90%AH,`P`J9A)4CC0N__Y*0FP$-#Q]QA8:8"IT`&`6,`+G0'(`$@/08
  90. XM0=!"T$(T``1"`#`6&G``$`-![(`#"#```@``9MH,0GW&9P8[?``@__XZ`@P#)
  91. XM`&AF!@C$``=@%@P#`&QF!@C$``9@"@P#`$QF!@C$``@6&BM*``QP`!`#8``!P
  92. XME&```Q8(!``'9PI8CB!N__PPAV`:"`0`!F<,,$=8CB)N__PBB&`(6(X@;O_\?
  93. XM,(=T`&```:Q8CB1N__PO"DZZ`ZHT``Q%?<983V<&M$5O`C0%8``!C%2.%B[_J
  94. XM_T'M_?PD2!"#=`%@``%X=`A@$`!$`$AV>'008`8(Q``$=`H,`P!89@A!^@*:]
  95. XM(`A@!D'Z`J,@""M`_?@(!``&9PA8CBPN__Q@&@@$``1G"E2.,&[__BP(8`I4<
  96. XMCG``,"[__BP`"`0`!&<*2H9L!D2&",0`!4'M__PD2`Q%?<9F`GH!2H9F!$I%X
  97. XM9R`P0B(((`9.N@*8(&W]^!4P```P0B(((`9.N@*2+`!FX$'M__R1RC0("`0`.
  98. XM`V=L#`,`;V842D)G"@P2`#!G"+1%;00Z`E)%8%(,`P!X9P8,`P!89D9*0F="S
  99. XM#!(`,&<\M$5L$$'M_?ZQRF0(%3P`,%)"8.P(!```9AH,;0`P__YF$C`"5$"PW
  100. XM;?_\;`@Z+?_\545@S!4#%3P`,%1"M$5L$$'M_?RQRF0(%3P`,%)"8.Q@3`1`'
  101. XM`"5G`/["!$``,V<`_M($0``+9P#^K%-`9P#^R%M`9P#^PEM`9P#^2E-`9P#^>
  102. XMJ%-`9P#^IE=`9P#^:%5`9P#^J%=`9P#^FF``_B0(!``$9R@(!``%9P85/``M_
  103. XM8!H(!``!9P85/``K8`X(!``"9P85/``@8`)30E)"WD((!```9@``B@QM`##_9
  104. XM_F9`"`0`!&<Z,`0"0``F9S(@4['K``1D#B!34I,0FG``$"K__V`.<``0&C\``
  105. XM+PM.N@'47$\,0/__9P``PE-M__Q30F`R(%.QZP`$9!`@4U*3$*W__W``$"W_=
  106. XM_V`0<``0+?__/P`O"TZZ`9Q<3PQ`__]G``"*4D<P+?_\4VW__+!";L(Z`C`":
  107. XM4T)*0&<L(%.QZP`$9`X@4U*3$)IP`!`J__]@#G``$!H_`"\+3KH!6%Q/#$#_Y
  108. XM_V=&8,P(!```9SHT!6`J(%.QZP`$9`X@4U*3$+P`('``<"!@##\\`"`O"TZZ:
  109. XM`21<3PQ`__]G$E)',"W__%-M__RP0F[*8`#[=G#_8`#[>C`Q,C,T-38W.#E!,
  110. XM0D-$148`,#$R,S0U-C<X.6%B8V1E9@!(YT@`0H1*@&H$1(!21$J!:@9$@0I$3
  111. XM``%A/DI$9P)$@$S?`!)*@$YU2.=(`$*$2H!J!$2`4D1*@6H"1(%A&B`!8-@OS
  112. XM`6$2(`$B'TJ`3G4O`6$&(A]*@$YU2.<P`$A!2D%F($A!-@$T`$)`2$"`PR(`D
  113. XM2$`R`H+#,`%"04A!3-\`#$YU2$$F`2(`0D%(04A`0D!T#]"`TX&V@6($DH-2+
  114. XM0%'*__),WP`,3G4@;P`$(`A*&&;\4TB1P"`(3G5(YP`@0>R!!"1(+PI.N@&P[
  115. XM6$_5_````!9![(*\M<AEZDS?!`!.=4CG/"`D;P`8."\`'"`*9P`!@C0J``QG5
  116. XM``%Z"`(`"68``7((`@`#9@`!:B!*T?P````,,!`"0._],(!*J@`(9AH,1/__P
  117. XM9@AP`$S?!#Q.=2\*3KH"<C0J``Q83P@"``YF,"!2L>H`"&,:/SP``2`2D*H`Z
  118. XM!"\`$"H`#DB`/P!.N@/D4$\DJ@`((&H`$-'2)4@`!`Q$__]F!'8`8`(6!"`2P
  119. XMD*H`""H`,`("0`"@9TH,1/__9R(@4E*2$(,@2M'\````##`0",``#C"`-`!!O
  120. XM^O\.*4B"]%*%#$3__V<,#`,`"F<&NJH`$&4$>/]@#"52``1P`!`#8`#_5`@"'
  121. XM``YG,$J%9QPO!2\J``@0*@`.2(`_`$ZZ!!)(P+"%3^\`"F9<($K1_`````PPS
  122. XM$`)`O_\P@`Q$__]F$B2J``@E:@`(``1P`!`#8`#_!D'Z_I0I2(+T($K1_```*
  123. XM``PP$`C```XP@"2J``@@:@`0T=(E2``$(%)2DA"#<``0`V``_M(@2M'\````I
  124. XM##`0",```C"`)6H`"``$)*H`"'#_8`#^LDY5__9(YS@@)&T`"'0`(`IG!DIJM
  125. XM``QF"G#_3-\$'$Y=3G4(*@`!``QF"B\*3KH`HH1`6$\0*@`.2(`_`$ZZ!B*$D
  126. XM0`@J````#51/9PHO*@`(3KH!0EA/2FH`%&=22'H`;DAM__=.N@'\."H`%'8`S
  127. XM4$\P!$A`0D!(0(#\``I(0`9``#!R!Y)#0>W_]Q&`$`!(1$)$2$2(_``*4D,,)
  128. XM0P`%;=!"+?__2&W_]TZZ`JQ83T*20JH`!$*J``A":@`,2D)G!G#_8`#_5G``W
  129. XM8`#_4%1-4`!(YP`@)&\`""`*9D)![($$)$A*:@`,9R0P*@`,`D`""&8:/SS_Q
  130. XM_R\*3KK];@Q`__]<3V8(</],WP0`3G75_````!9![(*\M<AER'``8.@_//__<
  131. XM+PI.NOU"7$]@VDCG("`D;P`,=$$0*@`.2(`_`$ZZ`3!*0%1/9P)T(25\```$`
  132. XM```02'@$`$ZZ`+PE0``(6$]F&"5\`````0`0($K1_`````\E2``(-#P`@"!*Q
  133. XMT?P````,A5`E:@`(``0DJ@`(3-\$!$YU2.<`,)?+)&R"^&`0($I0B")O``RSB
  134. XMR&<.)DHD4B`*9NQ,WPP`3G4@"V<$)I)@!"E2@OA(YP`"("H`!%"`(DHL;(+&;
  135. XM3J[_+DS?0`!@U$CG`#`D;(+X8!PF4DCG``(@*@`$4(`B2BQL@L9.KO\N3-]`4
  136. XM`"1+(`IFX$*L@OA,WPP`3G5(YR`@)"\`#$J"9@AP`$S?!`1.=4CG``)R`"`"T
  137. XM4(`L;(+&3J[_.DS?0``D0$J`9@1P`&#:0?K_EBE(@OPDK(+X)4(`!"E*@O@@3
  138. XM"E"`8,!,[P,```0@"!#99OQ.=4CG("`T+P`,,`+!_``&)$#5[(+62D)M"K1LE
  139. XM@KQL!$J29@XY?``#@P!P_TS?!`1.=4CG``(P`L'\``8@;(+6(C`(`"QL@LY.X
  140. XMKO\H3-]``$J`9P1P`6`"<`!@T$CG,"`T+P`03KH!7#`"P?P`!B1`U>R"UDI"]
  141. XM;0JT;(*\;`1*DF8..7P``X,`</],WP0,3G5(YS`",&\`(E.()@@D+P`>(A(LY
  142. XM;(+.3J[_ODS?0`PF``R`_____V882.<``BQL@LY.KO]\3-]``#E`@P!P_V"Z8
  143. XM2.<P`G8`=``B$BQL@LY.KO^^3-]`#&"B2.<``B(O``@L;(+.3J[_N$S?0`!*S
  144. XM@&882.<``BQL@LY.KO]\3-]``#E`@P!P_TYU<`!@^DCG,"`T+P`03KH`G#`"Y
  145. XMP?P`!B1`U>R"UDI";0JT;(*\;`1*DF8..7P``X,`</],WP0,3G4P*@`$`D``I
  146. XM`V8*.7P`!H,`</]@Y@@J``,`!&<62.<P`G8!=``B$BQL@LY.KO^^3-]`#$CGC
  147. XM,`(F+P`B)"\`'B(2+&R"SDZN_]!,WT`,)@`,@/____]F&$CG``(L;(+.3J[_X
  148. XM?$S?0``Y0(,`</]@C"`#8(A(YR``2.<``B(\```0`'``+&R"QDZN_LY,WT``Z
  149. XM)``(```,9Q)*;(+>9@@@`DS?``1.=4ZZ``9P`&#R2.<P`G8$0?H`+B0(+P,OJ
  150. XM`BQL@LY.KO_$(@`D'R8?+&R"SDZN_]!,WT`,/SP``4ZZ``I43TYU7D,*`$JL2
  151. XM@P)G%"!L@P(@:``$3I`@;(,"*5"#`F#F2JR"]&<&(&R"]$Z0/R\`!$ZZ``94=
  152. XM3TYU2.<P`#!O``PF"$JL@M9G,'0`8`H_`DZZ`7)43U)"M&R"O&WP2.<``C`L(
  153. XM@KS!_``&(FR"UBQL@L9.KO\N3-]``$JL@OQG!B!L@OQ.D$JL@L)G%$CG``(BL
  154. XM+(+"+&R"SDZN_Z9,WT``2JR#!F<((&R#!B"L@PI*K(,.9Q1(YP`"(FR##BQLJ
  155. XM@L9.KOYB3-]``$JL@Q)G%$CG``(B;(,2+&R"QDZN_F),WT``2JR#%F<42.<`)
  156. XM`B)L@Q8L;(+&3J[^8DS?0`!*K(,:9Q1(YP`"(FR#&BQL@L9.KOYB3-]``$CG0
  157. XM``8L>``$""X`!`$I9Q!+^@`(3J[_XF`&0J?S7TYS*E]*K(+@9D!*K(+L9SA(G
  158. XMYP`",&R"ZB`((FR"["QL@L9.KO\N3-]``$CG``(P+(+H4D!(P.6`(FR"Y"QL+
  159. XM@L9.KO\N3-]``&`D2.<``BQL@L9.KO]\3-]``$CG``(B;(+@+&R"QDZN_H9,@
  160. XMWT``2.<``B)L@LXL;(+&3J[^8DS?0``@`RYL@M).=4S?``Q.=4CG("`T+P`,!
  161. XM,`+!_``&)$#5[(+62D)M"K1L@KQL!$J29@XY?``#@P!P_TS?!`1.=0@J``<`L
  162. XM!&822.<``B(2+&R"SDZN_]Q,WT``0I)P`&#:```#[`````$````!```#B@``'
  163. XM``````/R```#Z@```+$`("`@("`@("`@,#`P,#`@("`@("`@("`@("`@("`@C
  164. XM(""00$!`0$!`0$!`0$!`0$!`#`P,#`P,#`P,#$!`0$!`0$`)"0D)"0D!`0$!"
  165. XM`0$!`0$!`0$!`0$!`0$!`4!`0$!`0`H*"@H*"@("`@("`@("`@("`@("`@("N
  166. XM`@("0$!`0"``````````````````````````````````````````````````F
  167. XM`````````````````````````````````````````````````````````````
  168. XM`````````````````````````````````````````````````````````````
  169. XM```````````````````"`````````0``````````````````!``!``````$`)
  170. XM``````````````````0``@`````!````````````````````````````````'
  171. XM`````````````````````````````````````````````````````````````
  172. XM`````````````````````````````````````````````````````````````
  173. XM`````````````````````````````````````````````````````````````
  174. XM`````````````````````````````````````````````````````````````
  175. XM`````````````````````````````````````````````````````````````
  176. XM`````````````````````````````````````````````````````````````
  177. XM`````````````````````````````````````````````````````````````
  178. XM```````````````````````````````````````````````````4````````4
  179. X2``````/R```#ZP````$```/R9
  180. X``
  181. Xend
  182. Xsize 6588
  183. END_OF_FILE
  184. if test 9262 -ne `wc -c <'binaries/pasteclip.uu'`; then
  185.     echo shar: \"'binaries/pasteclip.uu'\" unpacked with wrong size!
  186. fi
  187. # end of 'binaries/pasteclip.uu'
  188. fi
  189. if test -f 'sources/handleiff.c' -a "${1}" != "-c" ; then 
  190.   echo shar: Will not clobber existing file \"'sources/handleiff.c'\"
  191. else
  192. echo shar: Extracting \"'sources/handleiff.c'\" \(11025 characters\)
  193. sed "s/^X//" >'sources/handleiff.c' <<'END_OF_FILE'
  194. X/*
  195. X**
  196. X**
  197. X**
  198. X**
  199. X**
  200. X*/
  201. X#include "handleiff.h"
  202. X#include "undefs.h"
  203. X#include "iffparse.pra"
  204. X#include <ctype.h>
  205. X
  206. X/*#####################*\
  207. X * Internal functions. *
  208. X\*#####################*/
  209. X/****************************\
  210. X * Name:     SeekStream     *
  211. X * Function: Move forward   *
  212. X * or backward in the file  *
  213. X * or in the clipboard      *
  214. X * relative where we are.   *
  215. X\****************************/
  216. Xlong
  217. XSeekStream(struct IFF *iff, long delta)
  218. X{
  219. X    long error;
  220. X
  221. X    geta4();
  222. X    TraceCall;
  223. X    if (iff->iff_Type==IOREQUEST) {
  224. X        IOReq(iff)->io_Offset += delta;
  225. X        error = SUCCESS;
  226. X    } else {
  227. X        if ((error = Seek(File(iff), delta, (long)OFFSET_CURRENT))>0)
  228. X            error = SUCCESS;
  229. X    }
  230. X    return error;
  231. X}
  232. X
  233. X/*******************************\
  234. X * Name:     WriteStream       *
  235. X * Function: Write data to the *
  236. X * stream (a file or the clip- *
  237. X * board).                     *
  238. X\*******************************/
  239. Xlong 
  240. XWriteStream(
  241. X    struct IFF *iff, 
  242. X    UBYTE *data, 
  243. X    long length)  
  244. X{
  245. X    long error;
  246. X
  247. X    geta4();
  248. X    TraceCall;
  249. X    if (iff->iff_Type==IOREQUEST) {
  250. X        IOReq(iff)->io_Command = CMD_WRITE;
  251. X        IOReq(iff)->io_Data = (UBYTE *)data;
  252. X        IOReq(iff)->io_Length = (long)length;
  253. X        DoClipIO(IOReq(iff));
  254. X        error = (long)-IOReq(iff)->io_Error;
  255. X    } else {
  256. X        error = Write(File(iff), (char *)data, length);
  257. X    }
  258. X    if (error>0)
  259. X        error = 0L;
  260. X    return error;
  261. X}
  262. X
  263. X/********************************\
  264. X * Name:     ReadStream         *
  265. X * Function: Read data from the *
  266. X * device (a file or the clip-  *
  267. X * board).                      *
  268. X\********************************/
  269. Xlong
  270. XReadStream(struct IFF *iff, UBYTE *data, long length)  
  271. X{
  272. X    long error;
  273. X
  274. X    geta4();
  275. X    TraceCall;
  276. X    if (iff->iff_Type==IOREQUEST) {
  277. X        IOReq(iff)->io_Command = CMD_READ;
  278. X        IOReq(iff)->io_Data = (UBYTE *)data;
  279. X        IOReq(iff)->io_Length = (long)length;
  280. X        DoClipIO(IOReq(iff));
  281. X        if (IOReq(iff)->io_Error==0)
  282. X            error = IOReq(iff)->io_Actual;
  283. X        else
  284. X            error = (long)-IOReq(iff)->io_Error;
  285. X    } else {
  286. X        error = Read(File(iff), (char *)data, length);
  287. X    }
  288. X    return error;
  289. X}
  290. X
  291. X/********************************\
  292. X * Name:     AlignStream        *
  293. X * Function: Align the read     *
  294. X * data so that it will be an   *
  295. X * even number of bytes.        *
  296. X\********************************/
  297. Xlong
  298. XAlignStream(struct IFF *iff)
  299. X{
  300. X    long error;
  301. X    
  302. X    geta4();
  303. X    TraceCall;
  304. X    if (iff->iff_Type==IOREQUEST) {
  305. X        if (IOReq(iff)->io_Offset%2)
  306. X            IOReq(iff)->io_Offset++;
  307. X        error = 0L;
  308. X    } else {
  309. X        if (Seek(File(iff), 0L, (long)OFFSET_CURRENT)%2)
  310. X            error = Seek(File(iff), 1L, (long)OFFSET_CURRENT);
  311. X    }
  312. X    if (error>0L)
  313. X        error = 0L;
  314. X    return error;
  315. X}
  316. X
  317. X
  318. X/*############################*\
  319. X * Public iffparse functions. *
  320. X\*############################*/
  321. X/********************\
  322. X * Initializations. *
  323. X\********************/
  324. Xlong
  325. XInitIFFasClip(struct IFF *iff)    
  326. X{
  327. X    geta4();
  328. X    TraceCall;
  329. X    iff->iff_Type = IOREQUEST;
  330. X    return SUCCESS;
  331. X}
  332. X
  333. Xlong
  334. XInitIFFasDOS(struct IFF *iff)
  335. X{
  336. X    geta4();
  337. X    TraceCall;
  338. X    iff->iff_Type = FILEHANDLE;
  339. X    return SUCCESS;
  340. X}
  341. X
  342. Xlong
  343. XOpenIFF(struct IFF *iff, long rwmode)
  344. X{
  345. X    geta4();
  346. X    TraceCall;
  347. X    IFFptr = 0;
  348. X    IFFStack[0].Size = 0;
  349. X    iff->iff_Flags = rwmode;
  350. X    if (iff->iff_Type==IOREQUEST) {
  351. X        if (rwmode==IFFF_READ)
  352. X            IOReq(iff)->io_Command = CMD_READ;
  353. X        else
  354. X            IOReq(iff)->io_Command = CMD_WRITE;
  355. X        IOReq(iff)->io_Offset = 0;
  356. X        IOReq(iff)->io_ClipID = 0;
  357. X    }
  358. X    return SUCCESS;
  359. X}
  360. X
  361. Xvoid
  362. XCloseIFF(struct IFF *iff)
  363. X{
  364. X    geta4();
  365. X    TraceCall;
  366. X    if (iff->iff_Type==IOREQUEST) {
  367. X        if ((iff->iff_Flags&IFFF_RWBITS)==IFFF_WRITE) { /* Make the clip public. */
  368. X            IOReq(iff)->io_Command = CMD_UPDATE;
  369. X            DoClipIO(IOReq(iff));
  370. X        } else {                        /* Flush the stuff that is not used. */
  371. X            long dummy;
  372. X            while (IOReq(iff)->io_Actual && !IOReq(iff)->io_Error) {
  373. X                IOReq(iff)->io_Data = (STRPTR)&dummy;
  374. X                IOReq(iff)->io_Length = 4;
  375. X                DoClipIO(IOReq(iff));
  376. X            }
  377. X        }
  378. X    }
  379. X}
  380. X
  381. Xstruct IFF *
  382. XAllocIFF(void)
  383. X{
  384. X    struct IFF *iff;
  385. X
  386. X    geta4();
  387. X    TraceCall;
  388. X    iff = NULL;
  389. X    if ((iff = AllocMem((long)sizeof(struct IFF), MEMF_PUBLIC|MEMF_CLEAR))==NULL)
  390. X        return NULL;
  391. X
  392. X    if ((iff->iff_Stack = AllocMem((long)sizeof(long)*256L, 0L))==NULL) {
  393. X        FreeMem((APTR)iff, (long)sizeof(struct IFF));
  394. X        iff = NULL;
  395. X    }
  396. X    return iff;
  397. X}
  398. X   
  399. Xvoid
  400. XFreeIFF(struct IFF *iff)
  401. X{
  402. X    geta4();
  403. X    TraceCall;
  404. X    if (iff) {
  405. X        if (iff->iff_Stack)
  406. X            FreeMem((APTR)iff->iff_Stack, (long)sizeof(long)*256L);
  407. X        FreeMem((APTR)iff, (long)sizeof(struct IFF));
  408. X    }
  409. X}
  410. X            
  411. Xstruct CBHandle *
  412. XOpenClipboard(long unit)
  413. X{
  414. X    struct Library *IFFParseBase;
  415. X    struct CBHandle *ch = NULL;
  416. X
  417. X    geta4();
  418. X    TraceCall;
  419. X    if ((ch = AllocMem((long)sizeof(struct CBHandle), MEMF_CLEAR))==NULL)
  420. X        goto fail;
  421. X    if ((ch->cbh_CBport = CreatePort(0L, 0L))==NULL)
  422. X        goto fail;
  423. X    if ((ch->cbh_SatisfyPort = CreatePort(0L, 0L))==NULL)
  424. X        goto fail;
  425. X    if ((ch->cbh_Req = (struct IOClipReq *)CreateExtIO(ch->cbh_CBport, 
  426. X                                                (long)sizeof(struct IOClipReq)))==NULL)
  427. X        goto fail;
  428. X    if (OpenDevice("clipboard.device", unit, (struct IORequest *)ch->cbh_Req, 0L)) {
  429. X        DeleteExtIO((struct IORequest *)ch->cbh_Req);
  430. X        ch->cbh_Req = NULL;
  431. X        goto fail;
  432. X    }
  433. X
  434. X    return ch;
  435. X
  436. Xfail:
  437. X    CloseClipboard(ch);
  438. X    return NULL;
  439. X}
  440. X
  441. Xvoid
  442. XCloseClipboard(struct CBHandle *ch)
  443. X{
  444. X    geta4();
  445. X    TraceCall;
  446. X    if (ch->cbh_Req) {
  447. X        CloseDevice((struct IORequest *)ch->cbh_Req);
  448. X        DeleteExtIO((struct IORequest *)ch->cbh_Req);
  449. X        ch->cbh_Req = NULL;
  450. X    }
  451. X    if (ch->cbh_CBport)
  452. X        DeletePort((struct MsgPort *)ch->cbh_CBport);
  453. X    if (ch->cbh_SatisfyPort)
  454. X        DeletePort((struct MsgPort *)ch->cbh_SatisfyPort);
  455. X    if (ch)
  456. X        FreeMem((APTR)ch, (long)sizeof(struct CBHandle));
  457. X}
  458. X
  459. X/*************************\
  460. X * Miscelous functions . *
  461. X\*************************/
  462. Xlong
  463. XNOOP()
  464. X{
  465. X    geta4();
  466. X    TraceCall;
  467. X    return FAILED;
  468. X}
  469. X
  470. Xvoid *
  471. XNULL_NOOP()
  472. X{
  473. X    geta4();
  474. X    TraceCall;
  475. X    return NULL;
  476. X}
  477. X
  478. XUBYTE *
  479. XIDtoStr(long ID, UBYTE *buf)
  480. X{
  481. X    geta4();
  482. X    TraceCall;
  483. X    *((long *)buf) = ID;
  484. X    buf[4] = '\0';
  485. X    return buf;
  486. X}
  487. X
  488. X#define ValidChar(l)    (isalpha(l) || ((l)==' '))
  489. X
  490. Xlong
  491. XGoodID(long ID)
  492. X{
  493. X    char *str = (char *)&ID;
  494. X
  495. X    geta4();
  496. X    TraceCall;
  497. X    return (long)(ValidChar(str[0])
  498. X                && ValidChar(str[1])
  499. X                && ValidChar(str[2])
  500. X                && ValidChar(str[3]));
  501. X}
  502. X
  503. Xlong
  504. XGoodType(long ID)
  505. X{
  506. X    char *str = (char *)&ID;
  507. X
  508. X    geta4();
  509. X    TraceCall;
  510. X    return (long)(ValidChar(str[0])
  511. X                && ValidChar(str[1])
  512. X                && ValidChar(str[2])
  513. X                && ValidChar(str[3]));
  514. X}
  515. X
  516. X/************************\
  517. X * The 'big' functions. *
  518. X\************************/
  519. Xlong
  520. XWriteChunkBytes(
  521. X    struct IFF *iff, 
  522. X    APTR data, 
  523. X    long size)
  524. X{
  525. X    long datasize = size;   /* Due to Manx bug! */
  526. X
  527. X    geta4();
  528. X    TraceCall;
  529. X    if (WriteStream(iff, (UBYTE *)data, datasize))
  530. X        return IFFERR_READ;
  531. X    IFFStack[IFFptr].Size += datasize;
  532. X    return 0L;
  533. X}
  534. X
  535. Xlong
  536. XReadChunkBytes(
  537. X    struct IFF *iff, 
  538. X    APTR data, 
  539. X    size_t size)
  540. X{
  541. X    long error;
  542. X    long datasize = size;   /* Due to Manx bug! */
  543. X
  544. X    geta4();
  545. X    TraceCall;
  546. X    if (data==NULL) {
  547. X        return IFFERR_SYNTAX;
  548. X    } else {
  549. X        if ((datasize==0) || (datasize>IFFStack[IFFptr].Size))
  550. X            datasize = IFFStack[IFFptr].Size;
  551. X    }
  552. X    if ((error=ReadStream(iff, (UBYTE *)data, datasize))<=0)
  553. X        if (error==0)
  554. X            return IFFERR_EOF;
  555. X        else
  556. X            return IFFERR_READ;
  557. X    IFFStack[IFFptr].Size -= datasize;
  558. X    if ((IFFStack[IFFptr].Size==0) && AlignStream(iff))
  559. X        return IFFERR_NOTIFF;
  560. X    return datasize;
  561. X}
  562. X
  563. Xlong
  564. XPushChunk(
  565. X    struct IFF *iff, 
  566. X    long type, 
  567. X    long id, 
  568. X    long size)
  569. X{
  570. X    long t_type = type;
  571. X
  572. X    geta4();
  573. X    TraceCall;
  574. X    if (WriteStream(iff, (UBYTE *)&id, 8L))
  575. X        return IFFERR_WRITE;
  576. X    if (t_type!=0L) {
  577. X        if (WriteStream(iff, (UBYTE *)&t_type, 4L))
  578. X            return IFFERR_WRITE;
  579. X        IFFStack[++IFFptr].Size=4;
  580. X    } else {
  581. X        IFFStack[++IFFptr].Size=0;
  582. X    }
  583. X    return 0L;
  584. X}
  585. X
  586. Xlong
  587. XPopChunk(struct IFF *iff)
  588. X{
  589. X    long offset;
  590. X    long size;
  591. X
  592. X    geta4();
  593. X    TraceCall;
  594. X    offset = IFFStack[IFFptr].Size;
  595. X    if (SeekStream(iff, -offset-4L))
  596. X        return IFFERR_SEEK;
  597. X    size = IFFStack[IFFptr].Size;
  598. X    if (WriteStream(iff, (UBYTE *)&size, 4L))
  599. X        return IFFERR_READ;
  600. X    if (IFFptr)
  601. X        IFFStack[--IFFptr].Size+=IFFStack[IFFptr+1].Size+8L;
  602. X    if (SeekStream(iff, offset))
  603. X        return IFFERR_SEEK;
  604. X    if (IFFStack[IFFptr+1].Size%2) {
  605. X        if (WriteStream(iff, (UBYTE *)"", 1L))
  606. X            return IFFERR_READ;
  607. X        IFFStack[IFFptr].Size++;
  608. X    }
  609. X    return 0L;
  610. X}
  611. X
  612. Xlong
  613. XParseIFF(struct IFF *iff, long control)
  614. X{
  615. X    struct IFFParseBase *IFFParseBase;
  616. X    long error;
  617. X    long type = 0L; 
  618. X    long id;
  619. X    long size;
  620. X
  621. X    geta4();
  622. X    TraceCall;
  623. X    if (control==IFFPARSE_RAWSTEP) {
  624. X        if (IFFptr && IFFStack[IFFptr].Size==0) {
  625. X            IFFptr--;
  626. X            iff->current.cn_ID = 0L;
  627. X            return IFFERR_EOC;
  628. X        } else if (IFFptr && IFFStack[IFFptr].Complex==0) {
  629. X            iff->current.cn_ID = 0L;
  630. X            if (SeekStream(iff, (long)(IFFStack[IFFptr].Size+((IFFStack[IFFptr].Size)&1))))
  631. X                return IFFERR_SEEK;
  632. X            IFFptr--;
  633. X            return IFFERR_EOC;
  634. X        }
  635. X        
  636. X        if ((error=ReadStream(iff, (UBYTE *)&id, 4L))<=0)
  637. X            if (error==0)
  638. X                return IFFERR_EOF;
  639. X            else
  640. X                return IFFERR_READ;
  641. X
  642. X        if (!GoodID(id))
  643. X            return IFFERR_NOTIFF;
  644. X
  645. X        if ((error=ReadStream(iff, (UBYTE *)&size, 4L))<=0)
  646. X            if (error==0)
  647. X                return IFFERR_EOF;
  648. X            else
  649. X                return IFFERR_READ;
  650. X
  651. X        if ((id==ID_FORM
  652. X        || id==ID_PROP
  653. X        || id==ID_CAT
  654. X        || id==ID_LIST)
  655. X        && ReadStream(iff, (UBYTE *)&type, 4L)<=0)
  656. X            return IFFERR_READ;
  657. X            
  658. X
  659. X        if (type!=0L) {
  660. X            IFFStack[IFFptr].Size -= size + (size%2) + 8L;
  661. X            IFFStack[++IFFptr].Size = size - 4L;
  662. X            IFFStack[IFFptr].Complex = 1;
  663. X            iff->current.cn_Type = type;
  664. X        } else {
  665. X            IFFStack[IFFptr].Size -= size + (size%2) + 8L;
  666. X            IFFStack[++IFFptr].Size = size;
  667. X            IFFStack[IFFptr].Complex = 0;
  668. X        }
  669. X        iff->current.cn_ID = id;
  670. X        iff->current.cn_Size = size;
  671. X        iff->current.cn_Scan = ((type!=0) ? 4 : 0);
  672. X        return SUCCESS;
  673. X    } else
  674. X        return FAILED;
  675. X}
  676. X
  677. Xstruct ContextNode*
  678. XCurrentChunk(struct IFF *iff)
  679. X{
  680. X    geta4();
  681. X    TraceCall;
  682. X    return &iff->current;
  683. X}
  684. END_OF_FILE
  685. if test 11025 -ne `wc -c <'sources/handleiff.c'`; then
  686.     echo shar: \"'sources/handleiff.c'\" unpacked with wrong size!
  687. fi
  688. # end of 'sources/handleiff.c'
  689. fi
  690. echo shar: End of archive 2 \(of 2\).
  691. cp /dev/null ark2isdone
  692. MISSING=""
  693. for I in 1 2 ; do
  694.     if test ! -f ark${I}isdone ; then
  695.     MISSING="${MISSING} ${I}"
  696.     fi
  697. done
  698. if test "${MISSING}" = "" ; then
  699.     echo You have unpacked both archives.
  700.     rm -f ark[1-9]isdone
  701. else
  702.     echo You still need to unpack the following archives:
  703.     echo "        " ${MISSING}
  704. fi
  705. ##  End of shell archive.
  706. exit 0
  707. -- 
  708. Mail submissions (sources or binaries) to <amiga@uunet.uu.net>.
  709. Mail comments to the moderator at <amiga-request@uunet.uu.net>.
  710. Post requests for sources, and general discussion to comp.sys.amiga.misc.
  711.